///Project: Introducing GLP Paper Table 8 Imputed data
///Stata 13


*****************************TABLE 8*****************************************
clear all
use "GLP_mi_15 05 31.dta"
drop if missing(occupation1)
count
gen temp=1
sort country_nid
by country_nid: egen alloccp=total(temp)
tab occupation1
save "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/occupation_mi8.dta", replace
count
count if power==1
count if power==3
count if office1==2
count if office1==7
count if office1==6
count if wealth==0
count if wealth==1
count if region==1
count if region==2
count if region==3
count if region==4
count if region==5
count if regime==0
count if regime==1
tab occupation1
save "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/occupation_mi8.dta", replace
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/occupation_mi8.dta", replace
duplicates drop country_nid, force
count
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/occupation_mi8.dta"
keep if power==1
duplicates drop country_nid, force
count
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/occupation_mi8.dta"
keep if power==3
duplicates drop country_nid, force
count
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/occupation_mi8.dta"
keep if office1==2
duplicates drop country_nid, force
count
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/occupation_mi8.dta"
keep if office1==6
duplicates drop country_nid, force
count
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/occupation_mi8.dta"
keep if office1==7
duplicates drop country_nid, force
count
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/occupation_mi8.dta"
keep if wealth==0
duplicates drop country_nid, force
count
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/occupation_mi8.dta"
keep if wealth==1
duplicates drop country_nid, force
count
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/occupation_mi8.dta"
keep if regime==0
duplicates drop country_nid, force
count
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/occupation_mi8.dta"
keep if regime==1
duplicates drop country_nid, force
count
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/occupation_mi8.dta"
keep if region==1
duplicates drop country_nid, force
count
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/occupation_mi8.dta"
keep if region==2
duplicates drop country_nid, force
count
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/occupation_mi8.dta"
keep if region==3
duplicates drop country_nid, force
count
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/occupation_mi8.dta"
keep if region==4
duplicates drop country_nid, force
count
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/occupation_mi8.dta"
keep if region==5
duplicates drop country_nid, force
count

**white collar**
//descriptive
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/occupation_mi8.dta"
keep if occupation1==1
sort country_nid
by country_nid: egen whitecol=total(temp) if occupation1==1
gen percentage=whitecol/alloccp*100
collapse (max) percentage, by(country country_nid)
merge m:1 country_nid using "Country_list.dta"
replace percentage=0 if _merge==2
sum percentage
return list
sum percentage if wealth==1
sum percentage if wealth==0
sum percentage if regime==0
sum percentage if regime==1
sum percentage if region==1
sum percentage if region==2
sum percentage if region==3
sum percentage if region==4
sum percentage if region==5
//offices
*apex*
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/occupation_mi8.dta"
keep if power==1
count
by country_nid: egen whitecol=total(temp) if occupation1==1 
by country_nid: egen all=total(temp)
gen percentage=whitecol/all*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage

*top ten*
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/occupation_mi8.dta"
keep if power==3
count
by country_nid: egen whitecol=total(temp) if occupation1==1 
by country_nid: egen all=total(temp)
gen percentage=whitecol/all*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage

*cabinet*
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/occupation_mi8.dta"
keep if office1==2 
count
by country_nid: egen whitecol=total(temp) if occupation1==1 
by country_nid: egen all=total(temp)
gen percentage=whitecol/all*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage

*court*
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/occupation_mi8.dta"
keep if office1==7 
count
by country_nid: egen whitecol=total(temp) if occupation1==1 
by country_nid: egen all=total(temp)
gen percentage=whitecol/all*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage

*mp*
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/occupation_mi8.dta"
keep if office1==6 
count
by country_nid: egen whitecol=total(temp) if occupation1==1 
by country_nid: egen all=total(temp)
gen percentage=whitecol/all*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage

//////////////////////////////////////////////////////////
**blue collar**
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/occupation_mi8.dta"
keep if occupation1==2 
sort country_nid
by country_nid: egen blucol=total(temp)
gen percentage=blucol/alloccp*100
duplicates drop country_nid, force
merge m:1 country_nid using "Country_list.dta"
replace percentage=0 if _merge==2
sum percentage
return list
sum percentage if wealth==1
sum percentage if wealth==0
sum percentage if regime==0
sum percentage if regime==1
sum percentage if region==1
sum percentage if region==2
sum percentage if region==3
sum percentage if region==4
sum percentage if region==5
*apex*
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/occupation_mi8.dta"
keep if power==1
by country_nid: egen blucol=total(temp) if occupation1==2
by country_nid: egen all=total(temp)
gen percentage=blucol/all*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage

*top ten*
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/occupation_mi8.dta"
keep if power==3
by country_nid: egen blucol=total(temp) if occupation1==2
by country_nid: egen all=total(temp)
gen percentage=blucol/all*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage

*cabinet*
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/occupation_mi8.dta"
keep if office1==2 
by country_nid: egen blucol=total(temp) if occupation1==2
by country_nid: egen all=total(temp)
gen percentage=blucol/all*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage

*court*
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/occupation_mi8.dta"
keep if office1==7 
by country_nid: egen blucol=total(temp) if occupation1==2
by country_nid: egen all=total(temp)
gen percentage=blucol/all*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage

*mp*
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/occupation_mi8.dta"
keep if office1==6 
by country_nid: egen blucol=total(temp) if occupation1==2
by country_nid: egen all=total(temp)
gen percentage=blucol/all*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage

////////////////////////////////////////////////////////////////
**education**
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/occupation_mi8.dta"
keep if occupation1==3
sort country_nid
by country_nid: egen edu=total(temp) 
gen percentage=edu/alloccp*100
duplicates drop country_nid, force
merge m:1 country_nid using "Country_list.dta"
replace percentage=0 if _merge==2
sum percentage
return list
sum percentage if wealth==1
sum percentage if wealth==0
sum percentage if regime==0
sum percentage if regime==1
sum percentage if region==1
sum percentage if region==2
sum percentage if region==3
sum percentage if region==4
sum percentage if region==5
*apex*
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/occupation_mi8.dta"
keep if power==1
by country_nid: egen edu=total(temp) if occupation1==3
by country_nid: egen all=total(temp)
gen percentage=edu/all*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage

*top ten*
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/occupation_mi8.dta"
keep if power==3
by country_nid: egen edu=total(temp) if occupation1==3
by country_nid: egen all=total(temp)
gen percentage=edu/all*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage

*cabinet*
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/occupation_mi8.dta"
keep if office1==2 
by country_nid: egen edu=total(temp) if occupation1==3
by country_nid: egen all=total(temp)
gen percentage=edu/all*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage

*court*
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/occupation_mi8.dta"
keep if office1==7 
by country_nid: egen edu=total(temp) if occupation1==3
by country_nid: egen all=total(temp)
gen percentage=edu/all*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage

*mp*
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/occupation_mi8.dta"
keep if office1==6 
by country_nid: egen edu=total(temp) if occupation1==3
by country_nid: egen all=total(temp)
gen percentage=edu/all*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage

///////////////////////////////////////////////////////////////
**media**
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/occupation_mi8.dta"
keep if occupation1==4
sort country_nid
by country_nid: egen media=total(temp) 
gen percentage=media/alloccp*100
duplicates drop country_nid, force
merge m:1 country_nid using "Country_list.dta"
replace percentage=0 if _merge==2
sum percentage
return list
sum percentage if wealth==1
sum percentage if wealth==0
sum percentage if regime==0
sum percentage if regime==1
sum percentage if region==1
sum percentage if region==2
sum percentage if region==3
sum percentage if region==4
sum percentage if region==5
*apex*
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/occupation_mi8.dta"
keep if power==1
by country_nid: egen media=total(temp) if occupation1==4
by country_nid: egen all=total(temp)
gen percentage=media/all*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage

*top ten*
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/occupation_mi8.dta"
keep if power==3
by country_nid: egen media=total(temp) if occupation1==4
by country_nid: egen all=total(temp)
gen percentage=media/all*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage

*cabinet*
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/occupation_mi8.dta"
keep if office1==2 
by country_nid: egen media=total(temp) if occupation1==4
by country_nid: egen all=total(temp)
gen percentage=media/all*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage

*court*
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/occupation_mi8.dta"
keep if office1==7 
by country_nid: egen media=total(temp) if occupation1==4
by country_nid: egen all=total(temp)
gen percentage=media/all*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage

*mp*
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/occupation_mi8.dta"
keep if office1==6 
by country_nid: egen media=total(temp) if occupation1==4
by country_nid: egen all=total(temp)
gen percentage=media/all*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage

//////////////////////////////////////////////////////////////
**military**
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/occupation_mi8.dta"
keep if occupation1==5
sort country_nid
by country_nid: egen military=total(temp) 
gen percentage=military/alloccp*100
duplicates drop country_nid, force
merge m:1 country_nid using "Country_list.dta"
replace percentage=0 if _merge==2
sum percentage
return list
sum percentage if wealth==1
sum percentage if wealth==0
sum percentage if regime==0
sum percentage if regime==1
sum percentage if region==1
sum percentage if region==2
sum percentage if region==3
sum percentage if region==4
sum percentage if region==5
//offices
*apex*
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/occupation_mi8.dta"
keep if power==1
by country_nid: egen military=total(temp) if occupation1==5
by country_nid: egen all=total(temp)
gen percentage=military/all*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage

*top ten*
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/occupation_mi8.dta"
keep if power==3
by country_nid: egen military=total(temp) if occupation1==5
by country_nid: egen all=total(temp)
gen percentage=military/all*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage

*cabinet*
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/occupation_mi8.dta"
keep if office1==2 
by country_nid: egen military=total(temp) if occupation1==5
by country_nid: egen all=total(temp)
gen percentage=military/all*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage

*court*
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/occupation_mi8.dta"
keep if office1==7 
by country_nid: egen military=total(temp) if occupation1==5
by country_nid: egen all=total(temp)
gen percentage=military/all*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage

*mp*
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/occupation_mi8.dta"
keep if office1==6 
by country_nid: egen military=total(temp) if occupation1==5
by country_nid: egen all=total(temp)
gen percentage=military/all*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage

///////////////////////////////////////////////////////
**none of pols**
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/occupation_mi8.dta"
keep if occupation1==6
sort country_nid
by country_nid: egen nonepols=total(temp) 
gen percentage=nonepols/alloccp*100
duplicates drop country_nid, force
merge m:1 country_nid using "Country_list.dta"
replace percentage=0 if _merge==2
sum percentage
return list
sum percentage if wealth==1
sum percentage if wealth==0
sum percentage if regime==0
sum percentage if regime==1
sum percentage if region==1
sum percentage if region==2
sum percentage if region==3
sum percentage if region==4
sum percentage if region==5
//offices
*apex*
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/occupation_mi8.dta"
keep if power==1
by country_nid: egen nonepols=total(temp) if occupation1==6
by country_nid: egen all=total(temp)
gen percentage=nonepols/all*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage

*top ten*
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/occupation_mi8.dta"
keep if power==3
by country_nid: egen nonepols=total(temp) if occupation1==6
by country_nid: egen all=total(temp)
gen percentage=nonepols/all*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage

*cabinet*
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/occupation_mi8.dta"
keep if office1==2 
by country_nid: egen nonepols=total(temp) if occupation1==6
by country_nid: egen all=total(temp)
gen percentage=nonepols/all*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage

*court*
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/occupation_mi8.dta"
keep if office1==7 
by country_nid: egen nonepols=total(temp) if occupation1==6
by country_nid: egen all=total(temp)
gen percentage=nonepols/all*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage

*mp*
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/occupation_mi8.dta"
keep if office1==6 
by country_nid: egen nonepols=total(temp) if occupation1==6
by country_nid: egen all=total(temp)
gen percentage=nonepols/all*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage

////////////////////////////////////////////////////////////////////
**other**
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/occupation_mi8.dta"
keep if occupation1==7
sort country_nid
by country_nid: egen other=total(temp) 
gen percentage=other/alloccp*100
duplicates drop country_nid, force
merge m:1 country_nid using "Country_list.dta"
replace percentage=0 if _merge==2
sum percentage
return list
sum percentage if wealth==1
sum percentage if wealth==0
sum percentage if regime==0
sum percentage if regime==1
sum percentage if region==1
sum percentage if region==2
sum percentage if region==3
sum percentage if region==4
sum percentage if region==5
//offices
*apex*
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/occupation_mi8.dta"
keep if power==1
by country_nid: egen other=total(temp) if occupation1==7
by country_nid: egen all=total(temp)
gen percentage=other/all*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage

*top ten*
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/occupation_mi8.dta"
keep if power==3
by country_nid: egen other=total(temp) if occupation1==7
by country_nid: egen all=total(temp)
gen percentage=other/all*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage

*cabinet*
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/occupation_mi8.dta"
keep if office1==2 
by country_nid: egen other=total(temp) if occupation1==7
by country_nid: egen all=total(temp)
gen percentage=other/all*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage

*court*
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/occupation_mi8.dta"
keep if office1==7 
by country_nid: egen other=total(temp) if occupation1==7
by country_nid: egen all=total(temp)
gen percentage=other/all*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage

*mp*
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/occupation_mi8.dta"
keep if office1==6 
by country_nid: egen other=total(temp) if occupation1==7
by country_nid: egen all=total(temp)
gen percentage=other/all*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage






